package mutsumimod.cards.custom;

import com.badlogic.gdx.graphics.Color;
import com.evacipated.cardcrawl.mod.stslib.fields.cards.AbstractCard.SoulboundField;
import com.megacrit.cardcrawl.actions.animations.VFXAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.vfx.combat.WeightyImpactEffect;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.util.CardStats;

public class Warship extends BaseCard {
    public static final String ID = makeID(Warship.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.ATTACK,
            CardRarity.RARE,
            CardTarget.ENEMY,
            3
    );

    public Warship() {
        super(ID, info);
        setAttr(0,0,10);
        setAttrUpg(0,0,-5);
        SoulboundField.soulbound.set(this, true);
        misc=70;
        baseDamage=misc;
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new VFXAction(new WeightyImpactEffect(m.hb.cX, m.hb.cY, Color.GOLD.cpy())));
        damageMonster(m);
        decreaseDamage();
    }

    @Override
    public void applyPowers() {
        baseDamage=misc;
        super.applyPowers();
        initializeDescription();
    }

    @Override
    public AbstractCard makeCopy() { //Optional
        return new Warship();
    }

    @Override
    public Warship makeStatEquivalentCopy(){
        Warship copy = (Warship) super.makeStatEquivalentCopy();
        copy.baseDamage=copy.misc;
        copy.initializeDescription();
        return copy;
    }

    public void decreaseDamage(){
        for (AbstractCard c : AbstractDungeon.player.masterDeck.group) {
            if (!c.uuid.equals(this.uuid))
                continue;
            c.misc -=magicNumber;
            c.applyPowers();
            c.baseDamage = c.misc;
            c.isDamageModified = false;
        }
        misc-=magicNumber;
        misc=Math.max(0,misc);
        applyPowers();
    }
}
